<!--  -->
<template>
  <div class='spin'>
    <a-spin size="large" />
  </div>
</template>

<script>
import * as api from "@/API/require"
export default {
  components: {},
  data () {
    return {

    };
  },
  computed: {},
  watch: {},
  methods: {
    async thirdLogin () {
      console.log(this.$route.query)
      await localStorage.setItem('userInfo', JSON.stringify({
        user: null,
        id: null,
        avatar: null,
        token: this.$route.query.token
      }))
      if (this.$route.query.type == 'weibo') {
        await api.weiboLogin({
          id: this.$route.query.id
        }).then(res => {
          if (res.data.code == 200) {
            this.$message.success(res.data.message)
            localStorage.setItem('userInfo', JSON.stringify(res.data.userInfo))
            this.$router.push('/home');
          } else {
            this.$message.error(res.data.message)
          }
        })
      } else {
        await api.thirdLogin({
          id: this.$route.query.id
        }).then(res => {
          if (res.data.code == 200) {
            this.$message.success(res.data.message)
            localStorage.setItem('userInfo', JSON.stringify(res.data.userInfo))
            this.$router.push('/home');
          } else {
            this.$message.error(res.data.message)
          }
        })
      }


    }
  },
  created () {
    this.thirdLogin()
  },
  mounted () {

  },
}
</script>
<style scoped>
.spin {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>